/***************************************************************************
 *  WlanSavvy
 *  Copyright  2007  Deepak Manoharan
 *  Email deepakm@gmail.com
 *  http://wlansavvy.googlecode.com/
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
#ifndef __WL_IF_H
#define __WL_IF_H

/* Standard headers */
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>              /* gethostbyname, getnetbyname */
#include <net/ethernet.h>       /* struct ether_addr */
#include <sys/time.h>           /* struct timeval */
#include <unistd.h>

#include <net/if_arp.h>         /* For ARPHRD_ETHER */
#include <sys/socket.h>         /* For AF_INET & struct sockaddr */
#include <netinet/in.h>         /* For struct sockaddr_in */
#include <netinet/if_ether.h>

#ifndef __user
#define __user
#endif

#include <linux/types.h>                /* for "caddr_t" et al          */
#include <sys/socket.h>                 /* for "struct sockaddr" et al  */
#include <linux/if.h>
#include <linux/wireless.h>

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gnome.h>
#include <glib.h>
#include "connectionpanel.h"

#define PROC_NET_WIRELESS "/proc/net/wireless"
typedef struct iw_statistics    iwstats;
typedef struct iw_range    iwrange;


typedef struct wl_info{
	/*Interface info*/
	gchar addr[4];	
	gchar mask[4];	
	gchar hwaddr[6];	

	/*Wireless info*/
	gchar name[IFNAMSIZ+1];
	
	gint has_essid;
	gint essid_on;
	gchar essid[IW_ESSID_MAX_SIZE+1];

	gint has_ap_addr;
    struct sockaddr ap_addr;

	gint has_freq;
	gfloat freq;

	gint has_bitrate;
	glong bitrate;

	gint has_sensitivity;
	glong sensitivity;

	gint has_mode;
	gint mode;

	gint has_txpower;
    gshort txpower_dbm;
    gfloat   txpower_mw;
	
	gint has_stats;
	iwstats stats;

	gint has_range;
	iwrange range;

    unsigned long long rx_packets, tx_packets;
    unsigned long long rx_bytes, tx_bytes;
	
	gint has_encryption;
	gchar key[IW_ENCODING_TOKEN_MAX];
	gint enc_val;

	gint has_rts;
	gint rts_val;
	gint rts_off;

	gint has_frag;
	gint frag_val;
	gint frag_off;

}wl_info_t;


gint load_wlan_interfaces();

void refresh_if_statistics();
void refresh_if_info();
void refresh_graph();
void init_wlif();

#endif

